home *** CD-ROM | disk | FTP | other *** search
/ PC World Komputer 2010 April / PCWorld0410.iso / pluginy Firefox / 8206 / 8206.xpi / content / dialogs / formDlg.js next >
Text File  |  2010-02-02  |  2KB  |  58 lines

  1. var formDlg = function() {
  2.     
  3.     var pub = {};
  4.     pub.prefs = Components.classes["@mozilla.org/preferences-service;1"].getService(Components.interfaces.nsIPrefService);
  5.     pub.edit = null;
  6.  
  7.     pub.onLoad = function()
  8.     {
  9.         var args = window.arguments[0];
  10.         
  11.         //var dialog = document.getElementById("wisestamp_form_dlg");
  12.         document.title = args.title;
  13.         
  14.         var container = document.getElementById("content");
  15.         
  16.         if (args.intro != undefined)
  17.         {
  18.             var intro = container.appendChild(document.createElement("description"));
  19.             intro.appendChild(document.createTextNode(args.intro));
  20.             
  21.             var separator = container.appendChild(document.createElement("separator"));
  22.             separator.setAttribute("class","thin");
  23.         }
  24.         
  25.         
  26.         var items = args.items;
  27.         for (id in items)
  28.             addItem(container,id,items[id]);
  29.     }
  30.     
  31.     pub.onAccept = function()
  32.     {
  33.         var settings = window.arguments[0].settings;
  34.         var items = window.arguments[0].items;
  35.         
  36.         for (id in items)
  37.         {
  38.             items[id].value = document.getElementById(id).value;
  39.         }
  40.             
  41.         window.arguments[0].settings = settings;
  42.         window.arguments[0].result = true;
  43.     }
  44.     
  45.     function addItem(container,id,param)
  46.     {
  47.           var hbox = container.appendChild(document.createElement("hbox"));
  48.     
  49.         var label = hbox.appendChild(document.createElement("label"));
  50.         label.setAttribute("value",param.label + ":");
  51.         label.setAttribute("width","70");
  52.         
  53.         var element = hbox.appendChild(document.createElement(param.type));
  54.         element.setAttribute("id",id);
  55.     }
  56.     
  57.     return pub;
  58. } ();